##########################################################################################
#### 20231211 ArchR分析步骤 ####

options(stringsAsFactors=F)
library(Seurat)
library(ArchR)
library(optparse)

##########################################################################################

option_list <- list(
    make_option(c("--cluster"), type = "character"),
    make_option(c("--work_dir"), type = "character")
)

if(1!=1){
  
  cluster <- "cluster0"
  work_dir <- "~/20231121_singleMuti/results/atac_res"

}

###########################################################################################

parseobj <- OptionParser(option_list=option_list, usage = "usage: Rscript %prog [options]")
opt <- parse_args(parseobj)
print(opt)

cluster <- opt$cluster
work_dir <- opt$work_dir

##########################################################################################
## counts数据，三批进行合并
count1_file <- paste0(work_dir,"/count/",cluster,"_testis01_count.Rdata",sep="")
count2_file <- paste0(work_dir,"/count/",cluster,"_testis02_count.Rdata",sep="")
count3_file <- paste0(work_dir,"/count/",cluster,"_testis03_count.Rdata",sep="")

b <- load(count1_file)
count1 <- cluster_testis_count
b <- load(count2_file)
count2 <- cluster_testis_count
b <- load(count3_file)
count3 <- cluster_testis_count

cluster_testis_count <- cbind(count1 , count2 , count3)

out_file <- paste0(work_dir,"/count/",cluster,"_testis_merge_peak_barcode_matrix.Rdata",sep="")
save(cluster_testis_count,file=out_file)
